import dayjs from 'dayjs';
//获取最七天时间戳
export function getTimestamp () {
	const currentDate = dayjs();
	const timestamps = Array.from({ length: 7 }, (_, index) =>
		currentDate.subtract(index, 'day').valueOf()
	);
	return [timestamps[timestamps.length - 1], timestamps[0],];
}

//获取最字符串数组
export function getTimestampString () {
	const currentDate = dayjs();
	const dateStrings = Array.from({ length: 7 }, (_, index) =>
		currentDate.subtract(index, 'day').format('YYYY-MM-DD')
	);
	return dateStrings[dateStrings.length - 1] + '~' + dateStrings[0];
}

export function formatDateStringRange (startDate, endDate) {
	return (
		dayjs(startDate).format('YYYY-MM-DD') +
		'~' +
		dayjs(endDate).format('YYYY-MM-DD')
	);
}

// 获取今天时间戳数组的函数
export function getTodayTimestamps () {
	const startOfDay = new Date(new Date().toLocaleDateString()).getTime(); // 获取今天零点时间的时间戳
	const endOfDay = new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1; // 获取今天23:59:59时间的时间戳
	return [startOfDay, endOfDay];
}